package com.guoby.springboot.controller;

import com.guoby.springboot.config.LimitConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by pactera on 2019/12/19.
 */
@RestController
public class HelloController {

    @Autowired
    private LimitConfig limitConfig;

    @GetMapping({"/hello", "/hi"})
    public String hello() {
        return "说明：" + limitConfig.getDescribe();
    }

    /***
     * 访问方式：http://127.0.0.1:8081/luckymoney/hello/110
     *
     * @param id
     * @return
     */
    @GetMapping("/hello/{id}")
    public String hello2(@PathVariable("id") Integer id) {
        return "id:" + id;
    }

    /***
     * 访问方式：http://127.0.0.1:8081/luckymoney/hello3?id=110
     *
     * @param id
     * @return
     */
    @GetMapping("/hello3")
    public String hello3(@RequestParam("id") Integer id) {
        return "id:" + id;
    }

    /***
     * 访问方式：http://127.0.0.1:8081/luckymoney/hello3?id=110
     *
     * @param myId
     * @return
     */
    @GetMapping("/hello4")
    public String hello4(@RequestParam(value = "id", required = false, defaultValue = "0") Integer myId) {
        return "id:" + myId;
    }


}
